home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / pascal / twait.pas < prev    next >
Pascal/Delphi Source File  |  1991-09-03  |  2KB  |  54 lines

  1. Unit TWait;
  2.  
  3. {  TWait is a way to display a message while the computer is crunching }
  4. {  numbers or processing data or whatever.  First, invoke Wait with    }
  5. {  the message you want to display, then call CloseWait to get rid of  }
  6. {  the message window.  It's really a simple approach to the problem,  }
  7. {  and some of you may not like the way I get rid of the window, but   }
  8. {  you can change it to suit your needs.  Donated to the public domain }
  9. {  but please let me know of any interesting changes to it!            }
  10. (*  Sample use:
  11.     program TestWait;
  12.     var PW: PWindow;
  13.      { init TV and all the goodies }
  14.     ...
  15.       PW:=Wait('Please wait...Processing data');
  16.         { do your number crunching here }
  17.       CloseWait(PW);
  18.     ...   *)
  19. { as you can see, Wait will display a message window while your program   }
  20. { is doing it's dirty deeds, and can then be closed when you are finished }
  21. { doing whatever you did.                                                 }
  22. {  Send comments to Ty Brewer, CompuServe 72740,3230                      }
  23.  
  24.  
  25. interface
  26. uses Views, Drivers, Objects, Dialogs, App;
  27.  
  28. function Wait(AMessage: string): PWindow;
  29. procedure CloseWait(AWin: PWindow);
  30. implementation
  31.  
  32. function Wait(AMessage: string): PWindow;
  33. var
  34.   PW    : PWindow;
  35.   R    : TRect;
  36. begin
  37.   R.Assign(8, 2, 58, 8);
  38.   PW:=New(PWindow, Init(R, 'Message', 99));
  39.   PW^.Palette:=wpCyanWindow;
  40.   PW^.State:=PW^.State and not(sfShadow);
  41.   PW^.Options:=PW^.Options or (ofCentered) and not(ofSelectable);
  42.   PW^.Flags:=PW^.Flags and not ((wfMove) or (wfGrow) or (wfZoom));
  43.   R.Assign(1, 2, 49, 5);
  44.   PW^.Insert(New(PStaticText, Init (R, ^C+AMessage)));
  45.   DeskTop^.Insert(PW);
  46.   Wait:=PW;
  47. end;
  48.  
  49. procedure CloseWait(AWin: PWindow);
  50. begin
  51. message(AWin, evCommand, cmClose, nil);
  52. end;
  53.  
  54. end.